<h3>结题验收申请书列表</h3>
<table id="subject-final-list-table"></table>
<div id="subject-final-list-page" class="page-box"></div>
<script type="text/javascript">
    $(function () {
        getSubjectFinalList($pageNum);
    });

    var subjectFinalListXhr;
    function getSubjectFinalList(pageNum) {
        if (subjectFinalListXhr) subjectFinalListXhr.abort();
        subjectFinalListXhr = $.ajax({
            url: "/api/subject/final/list",
            type: "get",
            data: "page_num=" + pageNum,
            dataType: "json",
            beforeSend: function() {
            },
            complete: function() {
            },
            success: function (result) {
                if (result.code == 200) {
                    var data = result.data;
                    var list = data.list;

                    var tr = "";
                    for (x in list) {
                        tr += '<tr data-id="' + list[x].id + '">'
                            + '<td>' + list[x].subject.name + '</td>'
                            + '<td>' + list[x].subject.user.realname + '</td>'
                            + '<td>' + list[x].subject.classification.desc + '</td>'
                            + '<td>' + list[x].state.desc + '</td>'
                            + '<td>' + initOperate(list[x].subject_id, list[x].state.value) + '</td>'
                            + '</tr>';
                    }

                    var headTr = '<tr>'
                        + '<th>标题</th>'
                        + '<th>支持人</th>'
                        + '<th>学科</th>'
                        + '<th>进度</th>'
                        + '<th>操作</th>'
                        + '</tr>';
                    $("#subject-final-list-table").html(headTr + tr);

                    initPage($("#subject-final-list-page"), data, getSubjectFinalList);
                }
            },error: function (result) {

            }
        });
    }

    function initOperate(subject_id, state) {
        var str = '<a data-url="/subject/' + subject_id + '/final/show/subject" onclick="openPage(this)">浏览</a>';
        switch (state) {
            case 4:
                return str += '<a data-url="/subject/' + subject_id + '/final/check/returnback" onclick="openPage(this)">退回</a>'
                    + '<a data-url="/subject/' + subject_id + '/final/check/approval" onclick="openPage(this)">会议意见</a>';
            case 5:
                return str += '<a data-url="/subject/' + subject_id + '/final/check/firsttrial" onclick="openPage(this)">结题初审</a>';
            case 6:
                return str += '<a data-url="/subject/' + subject_id + '/final/check/finaltrial" onclick="openPage(this)">结题终审</a>';
        }
        return str;
    }
</script>